/**
 * @author David Young
 */
package csab.game.sprites;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import csab.core.ResourceManager;
import csab.game.MeleeAIController;

/**
 * A sprite which walks back and forth on a
 * piece of terrain.
 * @author David Young
 */
public final class PlatformBotSprite extends PlatformAISprite {
	private ResourceManager mgr;
	
	public PlatformBotSprite() throws SlickException {
		mgr = ResourceManager.getManager("resource/resources.xml");
		Animation animlw = mgr.getAnimation("pbot_left_walk");
		Animation animrw = mgr.getAnimation("pbot_right_walk");
		Animation animfwd = mgr.getAnimation("pbot_fwd_idle");
		
		Image [] idlet = new Image[1];
		
		idlet[0] = animlw.getImage(0);
		Animation animlidle = new Animation(idlet, 1);
		animlidle.setLooping(false);
		animlidle.setAutoUpdate(false);
		animlidle.setCurrentFrame(0);
		
		idlet[0] = animrw.getImage(0);
		Animation animridle = new Animation(idlet, 1);
		animridle.setLooping(false);
		animridle.setAutoUpdate(false);
		animridle.setCurrentFrame(0);
		
		this.setWidth(idlet[0].getWidth());
		this.setHeight(idlet[0].getHeight());
		
		this.setController(new MeleeAIController(this));
		super.initAnims(animlw, animrw, animlidle, animridle, animfwd, animfwd, null, null);
	}
	
	/* (non-Javadoc)
	 * @see csab.core.Entity#destroy()
	 */
	@Override
	protected void destroy() {
		mgr.freeAnimation("player_left_walk");
		mgr.freeAnimation("player_right_walk");
		mgr.freeAnimation("player_fwd_idle");
	}

	/* (non-Javadoc)
	 * @see csab.core.Sprite#canAttack()
	 */
	@Override
	public boolean canAttack() {
		return false;
	}

	/* (non-Javadoc)
	 * @see csab.core.Sprite#doAttack()
	 */
	@Override
	public void doAttack() {}

	/* (non-Javadoc)
	 * @see csab.core.Sprite#prepareAttack()
	 */
	@Override
	public void prepareAttack() {
	}

	/* (non-Javadoc)
	 * @see csab.core.Sprite#readyToAttack()
	 */
	@Override
	public boolean readyToAttack() { return false; }

}
